package com.example.luckysystem.common.exception;

import com.example.luckysystem.common.errorcode.ErrorCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @version 1.0
 * @Author shangjialu
 * @Date 2024/12/4 21:30
 * @注释
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class ServiceException extends RuntimeException{
    private Integer code;//异常码
    private String message;//异常信息

    //添加无参构造主要是为了进行序列化
    public ServiceException(){

    }

    public ServiceException(Integer code,String message){
        this.code = code;
        this.message = message;
    }

    public ServiceException(ErrorCode errorCode) {
        this.code = errorCode.getCode();
        this.message = errorCode.getMsg();
    }
}
